<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 01:13:27
 * @LastEditTime: 2022-02-03 01:13:40
 * @LastEditors: CHINAKAIYUAN
 * @Description: 
 */

namespace App\Models;

use App\Traits\SoftDeletesTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Support\Facades\DB;

class Subscribe extends BaseModel
{
    use HasFactory, SoftDeletesTrait;

    public $table = "basedata_subscribe";
    protected $guarded = [];
    public function api()
    {
        return  $this->hasManyThrough(Api::class, SubscribeApi::class, "subscribe_id", "id", "id", "api_id");
    }
    public function subscribe_api()
    {
        return $this->hasMany(SubscribeApi::class);
    }

    public function status()
    {
        return  $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q) {
            $q->where("code", 'table_status');
        });
    }
}
